package com.android.webttest.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.android.webttest.model.tableModel.GoodShare;

@Dao
public interface GoodShareDao {

    @Insert
    void insert(GoodShare goodShare);

    @Query("DELETE FROM good_share")
    void deleteAll();

    @Query("SELECT * FROM good_share WHERE good_id = :goodId LIMIT 1")
    GoodShare loadByGoodId(Integer goodId);

    /**
     * 封装方法：判断是否存在记录
     */
    default boolean existsGoodShareByGoodId(Integer goodId) {
        return loadByGoodId(goodId) != null;
    }
}